package day20170424.homework;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import org.junit.Test;

public class HomeWork04 {
	/**
	 * 4： 使用Writer抽象类 (FileWriter) 把  "中深软通123" 写入到一个文件   io1704 cc.txt
	 * @throws Exception
	 */
	@Test
	public void homework04(){
		//字符输出流
		Writer writer = null;
		try {
			//定义输出的路径
			File src = new File("txt/cc.txt");
			//将路径写入输出流
			writer = new FileWriter(src);
			String str = "中深软通123";
			
			//存入记事本
			writer.write(str);
			writer.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}finally {
			if(null != writer){
				try {
					writer.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		
	}
}
